<template>
  <div class="work-order-detail-container">
    <!-- 返回按钮和标题 -->
    <el-page-header @back="$router.go(-1)" content="工单详情" class="detail-header">
    </el-page-header>

    <!-- 详情卡片 -->
    <el-card class="detail-card" shadow="hover">
      <div class="detail-content">
        <template v-if="Object.keys(workObj).length > 0">
          <div v-for="(value, key) in workObj" :key="key" class="detail-item">
            <span class="detail-label">{{ formatLabel(key) }}:</span>
            <span class="detail-value">{{ value || '--' }}</span>
          </div>
        </template>
        <el-empty v-else description="暂无工单数据"></el-empty>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      workObj: {}
    }
  },
  created() {
    this.workObj = this.$route.query;
  },
  methods: {
    formatLabel(key) {
      // 简单的键名格式化，将驼峰转为中文
      const labels = {
        'orderId': '工单ID',
        'orderName': '工单名称',
        'createTime': '创建时间',
        'status': '状态',
        'description': '描述',
        'assignee': '负责人',
        'priority': '优先级'
      };
      return labels[key] || key;
    }
  }
}
</script>

<style scoped>
.work-order-detail-container {
  padding: 20px;
  background-color: #f5f7fa;
  min-height: calc(100vh - 60px);
}

.detail-header {
  margin-bottom: 20px;
  padding: 10px 20px;
  background-color: #fff;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
}

.detail-card {
  border-radius: 8px;
  border: none;
}

.detail-content {
  padding: 20px;
}

.detail-item {
  display: flex;
  margin-bottom: 16px;
  line-height: 1.6;
  font-size: 14px;
  border-bottom: 1px dashed #ebeef5;
  padding-bottom: 12px;
}

.detail-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.detail-label {
  color: #909399;
  width: 120px;
  flex-shrink: 0;
  font-weight: 500;
}

.detail-value {
  color: #606266;
  flex: 1;
  word-break: break-all;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .detail-item {
    flex-direction: column;
  }

  .detail-label {
    width: 100%;
    margin-bottom: 4px;
  }
}
</style>